package com.settlement.system.common.enums;


import com.settlement.system.common.util.common.EnumUtil;

import java.util.Optional;

/**
 *
 * 描述: 记账状态枚举  <br>
 * 记账状态: (0:历史单据归档，1:未推送NC，2:推送NC中，3:推送NC失败，4:推送NC成功，5:撤销推送失败，6:附件归集成功，7:附件归集失败) <br>
 * @author hc <br>
 */
public enum NcAccountStatusEnum implements Code<Integer>{

	/** 0:历史单据归档 */HISTORY_DOCUMENT(0, "历史单据归档"),
	/** 1:未推送NC */NOT_PUSH(1, "未推送NC"),
	/** 2:推送NC中 */PUSH_IN(2,"推送NC中"),
	/** 3:推送NC失败 */PUSH_FAIL(3,"推送NC失败"),
	/** 4:推送NC成功 */PUSH_SUCC(4,"推送NC成功"),
	/** 5:撤销推送失败 */BACKOUT_FAIL(5,"撤销推送失败"),
	/** 6:附件归集中 */ANNEX_COL_IN(6,"附件归集中"),
	/** 7:附件归集成功 */ANNEX_COL_SUCC(7,"附件归集成功"),
	/** 8:附件归集失败 */ANNEX_COL_FAIL(8,"附件归集失败")
	;

	private final Integer code;
	private final String name;

	NcAccountStatusEnum(Integer code, String name){
		this.code = code;
		this.name=name;
	}


	public static String getName(Integer code){
		return Optional.ofNullable(witch(code)).map(i->i.name).orElse(null);
	}

	@Override
	public Integer code(){
		return code;
	}

	/**
	 * 数值获取对应的 NcAccountStatusEnum
	 * @param code 数值
	 * @return 对应的枚举
	 */
	public static NcAccountStatusEnum witch(Integer code){
		return EnumUtil.witch(code, NcAccountStatusEnum.class,NOT_PUSH);
	}
}